package ae.pcfc.cldos.online.common.etksdb.domain.manager.provider;

import java.util.Collection;
import java.util.List;

import ae.pcfc.cldos.online.common.etksdb.dao.UserDAO;
import ae.pcfc.cldos.online.common.etksdb.domain.User;
import ae.pcfc.cldos.online.common.etksdb.domain.manager.UserDomainObjectManager;
import ae.pcfc.cldos.online.common.exception.LookupException;
import ae.pcfc.cldos.online.common.exception.PersistenceException;

public class UserDomainObjectManagerImpl implements UserDomainObjectManager {

	private UserDAO userDAO;

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	public <T> void add(T obj) throws PersistenceException {
		
		this.userDAO.add((User) obj);

	}

	public <T> void update(T obj) throws PersistenceException {
		
		this.userDAO.update((User) obj);

	}
	
	public User findUserAndClientByUserName(String strUserName) {
		return this.userDAO.findUserAndClientByUserName(strUserName);
	}

	public <T> void delete(T obj) throws PersistenceException {
		// TODO Auto-generated method stub

	}

	@SuppressWarnings("unchecked")
	public <T> T findByPrimaryKey(String id) throws LookupException {
		return (T) this.userDAO.finByPrimaryKey(Long.valueOf(id));
	}

	public <T> Collection<T> findAll() throws LookupException {
		// TODO Auto-generated method stub
		return null;
	}

	public User findUserByUserName(String userName) {

		return this.userDAO.findUserByUserName(userName);
	}

	public List<User> getUserList() {

		return this.userDAO.getUserList();
	}
	
	public User findUserById(Long userId){
		return userDAO.finByPrimaryKey(userId);
	}

	public List<String> getSubUsersEmailsListByCliendId(Long clientId) {
		return userDAO.getSubUsersEmailsListByCliendId(clientId);
	}

	public List<String> getMainUsersEmailsListByCliendId(Long clientId) {
		return userDAO.getMainUsersEmailsListByCliendId(clientId);
	}

	public List<String> getUsersEmailsListByCliendId(Long clientId) {
		return userDAO.getUsersEmailsListByCliendId(clientId);
	}

	public String getUserEmailById(Long userId) {
		return userDAO.getUserEmailById(userId);
	}
}
